<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Richieste aiuto</title>
</head>
<body>
   <form name="bacheca" method="post" action="BachecaServlet">
      <input type="hidden" name="username" value="<%=request.getAttribute("username") %>">
      <input type="hidden" name="nome" value="<%=request.getAttribute("nome") %>">
      <input type="hidden" name="cognome" value="<%=request.getAttribute("cognome") %>">
   </form>
   <form name="notifiche" method="post" action="NotificheServlet">
      <input type="hidden" name="username" value="<%=request.getAttribute("username") %>">
      <input type="hidden" name="nome" value="<%=request.getAttribute("nome") %>">
      <input type="hidden" name="cognome" value="<%=request.getAttribute("cognome") %>">
   </form>
    <form name="ricerca" method="post" action="Ricerca.jsp">
      <input type="hidden" name="id" value="<%=request.getAttribute("username") %>">
      <input type="hidden" name="nome" value="<%=request.getAttribute("nome") %>">
      <input type="hidden" name="cognome" value="<%=request.getAttribute("cognome") %>">
   </form>
   <div id="menu-wrapper">
		<div id="menu">
			<ul>
				<li><a href="javascript:document.bacheca.submit()">Bacheca</a></li>
      			<li><a href="javascript:document.notifiche.submit()">Notifiche</a></li>
      			<li><a href="MostraMioProfiloServlet?id=<%= request.getAttribute("username") %>"><%= request.getAttribute("nome") %><%= request.getAttribute("cognome") %></a></li>
      			<li><a href="javascript:document.ricerca.submit()">Ricerca</a></li>
      			<li><a href="LogoutServlet?username=<%= request.getAttribute("username")%>&user=utente">Logout</a></li>
			</ul>
		</div>
		<!-- end #menu -->
	</div>
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<h2 class="title">Richieste Aiuto</h2>
						<div class="entry">
						<%
						   int size = Integer.parseInt(request.getAttribute("size").toString());
						
						   if(size == 0) {
							   
							   out.println("Nessuna richiesta trovata");
							   
						   }
						   else {
							   
							   for(int i = 0; i < size; i++) {
						   		   
						 		     out.println("<form method=\"post\">");
						 		     out.println("<a href=\"ProfiloUtenteServlet?username=" + request.getAttribute("richiedente" + i) + "&id=" + request.getAttribute("username") + "&from=aiuto\">");
						 		     out.println(request.getAttribute("richiedente" + i));
						 		     out.println("</a><br/>");
						 		     int anno = Integer.parseInt(request.getAttribute("anno" + i).toString()) + 1900;
						 		     int mese = Integer.parseInt(request.getAttribute("mese" + i).toString()) + 1;
						 		     int giorno = Integer.parseInt(request.getAttribute("giorno" + i).toString());
						 		     int ore = Integer.parseInt(request.getAttribute("ore" + i).toString());
						 		     int minuti = Integer.parseInt(request.getAttribute("minuti" + i).toString());
						 		     int secondi = Integer.parseInt(request.getAttribute("secondi" + i).toString());
						 		     out.println("Data richiesta " + giorno + "-" + mese + "-" + anno + " " + ore + ":" + minuti + ":" + secondi + "<br/>");
						 		     out.println("Oggetto " + request.getAttribute("oggetto" + i) + "<br/>");
						 		     out.println("Descrizione: <br/>");
						 		     out.println(request.getAttribute("descrizione" + i) + "<br/>");
						 		     out.println("<input type=\"hidden\" name=\"richiedente\" value=\"" + request.getAttribute("richiedente" + i) +  "\">");
						 		     out.println("<input type=\"hidden\" name=\"destinatario\" value=\"" + request.getAttribute("username") +  "\">");
						 		     out.println("<input type=\"hidden\" name=\"data\" value=\"" + request.getAttribute("data" + i) +  "\">");
						 		     out.println("<input type=\"hidden\" name=\"nome\" value=\"" + request.getAttribute("nome") +  "\">");
						 		     out.println("<input type=\"hidden\" name=\"cognome\" value=\"" + request.getAttribute("cognome") +  "\">");
						 		     out.println("<input type=\"submit\" value=\"Accetta\" onClick=\"this.form.action='AccettaRicAiutoServlet'\">");
						 		     out.println("<input type=\"submit\" value=\"Rifiuta\" onClick=\"this.form.action='RifiutaRicAiutoServlet'\">");
						 		     out.println("</form>");
						 		     
						 	   }
							   
						   }
						%>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>